// Copyright (c) Symbian Ltd 2008. All rights reserved.

// INCLUDE FILES
#include <avkon.hrh>
#include <rps_0xA00054BC.rsg>

#include "common.hrh"
#include "rps.hrh"
#include "rpsApplication.h"
#include "rpsAppUi.h"
#include "rpsAppView.h"

TInt gScreenWidth;
TInt gScreenHeight;

// -----------------------------------------------------------------------------
// CRpsAppUi::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CRpsAppUi::ConstructL()
	{
	// Initialise app UI with standard value.
	BaseConstructL(CAknAppUi::EAknEnableSkin);

	// Remove key blocking.
	SetKeyBlockMode(ENoKeyBlock);
	
	gScreenWidth = ClientRect().Width();
	gScreenHeight = ClientRect().Height();
	
	iGameEngine = CRpsGameEngine::NewL(*this);

	// Create view object
	iAppView = CRpsAppView::NewL(*iGameEngine, ClientRect());
	AddToStackL(iAppView);

	}
// -----------------------------------------------------------------------------
// CRpsAppUi::CRpsAppUi()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CRpsAppUi::CRpsAppUi()
	{
	// No implementation required
	}

// -----------------------------------------------------------------------------
// CRpsAppUi::~CRpsAppUi()
// Destructor.
// -----------------------------------------------------------------------------
//
CRpsAppUi::~CRpsAppUi()
	{
	delete iGameEngine;
	if (iAppView)
		{
		RemoveFromStack(iAppView);
		delete iAppView;
		}
	}

// -----------------------------------------------------------------------------
// CRpsAppUi::HandleCommandL()
// Takes care of command handling.
// -----------------------------------------------------------------------------
//
void CRpsAppUi::HandleCommandL( TInt aCommand )
	{
	switch( aCommand )
		{
		case EEikCmdExit:
		case EAknSoftkeyExit:
		case EAknSoftkeyBack:
			Exit();
			break;
		default:
			ASSERT(EFalse); // Should not get here
			break;
		}
	}
// -----------------------------------------------------------------------------
//  Called by the framework when the application status pane
//  size is changed.  Passes the new client rectangle to the
//  AppView
// -----------------------------------------------------------------------------
//
void CRpsAppUi::HandleStatusPaneSizeChange()
	{
	iAppView->SetRect( ClientRect() );
	} 

void CRpsAppUi::UpdateScreen()
	{
	iAppView->DrawNow();
	}

// End of File
